//
//  GZTest.m
//  sinaweibo
//
//  Created by mac book pro on 16/3/22.
//  Copyright © 2016年 finish. All rights reserved.
//

#import "GZTest.h"

@implementation GZTest
-(void)test{
//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(<#delayInSeconds#> * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        <#code to be executed after a specified delay#>
//    });
}
-(void)test2{
    dispatch_group_t group = dispatch_group_create();
    dispatch_queue_t queue = dispatch_queue_create("queuq", DISPATCH_QUEUE_SERIAL);
    dispatch_group_async(group, queue, ^{
        [NSThread sleepForTimeInterval:2];
        NSLog(@"任务1");
    });
    dispatch_group_async(group, queue, ^{
       // [NSThread sleepForTimeInterval:2];
        NSLog(@"任务2");
    });
    NSLog(@"任务结束");
    dispatch_group_notify(group, queue, ^{
        NSLog(@"任务1任务2完成l");
    });
}
-(void)test3{
    dispatch_group_t group = dispatch_group_create();
    dispatch_queue_t queue = dispatch_queue_create("queuq", DISPATCH_QUEUE_SERIAL);
//    dispatch_group_async(group, queue, ^{
//        [NSThread sleepForTimeInterval:2];
//        NSLog(@"任务1");
//    });
    dispatch_group_enter(group);
    dispatch_async(queue, ^{
        [NSThread sleepForTimeInterval:2];
                NSLog(@"任务1");
        dispatch_group_leave(group);
    });
    dispatch_group_enter(group);
    dispatch_async(queue, ^{
        [NSThread sleepForTimeInterval:2];
        NSLog(@"任务2");
        dispatch_group_leave(group);
    });
    NSLog(@"任务结束");
    dispatch_group_notify(group, queue, ^{
        NSLog(@"任务1任务2完成l");
    });
}
@end
